//
//  ZiYuanZhouQiViewAlertView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/25.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "ZiYuanZhouQiViewAlertView.h"

@implementation ZiYuanZhouQiViewAlertView

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    //W372  H218
    self.backgroundColor = [UIColor whiteColor];
    self.layer.cornerRadius = 5;
    self.layer.masksToBounds = YES;
    [self addSubview:self.titleLabel];
    [self addSubview:self.closeButton];
    [self addSubview:self.startLabel];
    [self addSubview:self.giveDateButton];
    [self addSubview:self.endLabel];
    [self addSubview:self.fadebackDateButton];
}
- (void)layout{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(@14);
        make.height.equalTo(@14);
        make.left.equalTo(@0);
        make.right.equalTo(@0);
    }];
    [_closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-24);
        make.centerY.equalTo(self->_titleLabel.mas_centerY);
        make.height.equalTo(@15);
        make.width.equalTo(@15);
    }];
    [_startLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0).offset(14);
        make.right.equalTo(self.mas_right).offset(-290);
        make.top.equalTo(@0).offset(34+40);
        make.height.equalTo(@13);
    }];
    [_giveDateButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_startLabel.mas_right).offset(13);
        make.right.equalTo(self.mas_right).offset(-30);
        make.centerY.equalTo(self->_startLabel.mas_centerY);
        make.height.equalTo(@30);
    }];
    
    
    [_endLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_startLabel.mas_left);
        make.right.equalTo(self.mas_right).offset(-290);
        make.top.equalTo(self->_startLabel.mas_bottom).offset(45);
        make.height.equalTo(@13);
    }];
    [_fadebackDateButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_endLabel.mas_right).offset(13);
        make.right.equalTo(self.mas_right).offset(-30);
        make.centerY.equalTo(self->_endLabel.mas_centerY);
        make.height.equalTo(@30);
    }];
    
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"设置发放资源周期";
        label.textColor = SELECTEDCOLOR;
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        _titleLabel = label;
    }
    return _titleLabel;
}
- (UILabel *)startLabel{
    if (!_startLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"发放日期：";
        label.textColor = TITLECOLOR;
        label.textAlignment = 2;
        label.font = [UIFont systemFontOfSize:14];
        _startLabel = label;
    }
    return _startLabel;
}
- (UILabel *)endLabel{
    if (!_endLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"回收日期：";
        label.textColor = TITLECOLOR;
        label.textAlignment = 2;
        label.font = [UIFont systemFontOfSize:14];
        _endLabel = label;
    }
    return _endLabel;
}
- (UIButton *)closeButton{
    if (!_closeButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:@"fudao_close-1"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(closeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        _closeButton = button;
    }
    return _closeButton;
}
- (void)closeButtonClick:(UIButton *)sender{
    self.dismissBlock();
}
- (UIButton *)confiemButton{
    if (!_confiemButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:@"boFang_image"] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        [button setTitleColor:SELECTEDCOLOR forState:0];
        [button addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
        _confiemButton = button;
    }
    return _confiemButton;
}
- (void)back:(UIButton *)sender{
    self.confirmBlock();
}
- (ZXFDCSelectedView *)giveDateButton{
    if (!_giveDateButton) {
        ZXFDCSelectedView *view = [[ZXFDCSelectedView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        view.layer.cornerRadius = 2;
        view.layer.borderColor = [UIColorChange colorwithHexString:@"#999999"].CGColor;
        view.layer.borderWidth = 1;
        view.nameLabel.text = @"选择发放日期";
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(giveDateButtonClick:)];
        [view addGestureRecognizer:tap];
        _giveDateButton = view;
    }
    return _giveDateButton;
}
- (void)giveDateButtonClick:(UITapGestureRecognizer *)gesture{
    
}

- (ZXFDCSelectedView *)fadebackDateButton{
    if (!_fadebackDateButton) {
        ZXFDCSelectedView *view = [[ZXFDCSelectedView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        view.layer.cornerRadius = 2;
        view.layer.borderColor = [UIColorChange colorwithHexString:@"#999999"].CGColor;
        view.layer.borderWidth = 1;
        view.nameLabel.text = @"选择回收日期";
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(fadebackDateButtonClick:)];
        [view addGestureRecognizer:tap];
        _fadebackDateButton = view;
    }
    return _fadebackDateButton;
}
- (void)fadebackDateButtonClick:(UITapGestureRecognizer *)gesture{
    
}
- (void)drawRect:(CGRect)rect{
    UIBezierPath *path = [[UIBezierPath alloc]init];
    [path moveToPoint:CGPointMake(0, 40)];
    [path addLineToPoint:CGPointMake(self.frame.size.width,40)];
    [LINCOLOR set];
    [path stroke];
    
    UIBezierPath *pathBootom = [[UIBezierPath alloc]init];
    [pathBootom moveToPoint:CGPointMake(0, 178)];
    [pathBootom addLineToPoint:CGPointMake(self.frame.size.width,178)];
    [LINCOLOR set];
    [pathBootom stroke];
}
@end
